package top.codedance.iotp.tools.terminal.ui;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import top.codedance.iotp.common.constent.Command;
import top.codedance.iotp.tools.terminal.TerminalApplication;
import top.codedance.iotp.tools.terminal.bean.IntegerItem;

import java.awt.*;
import java.awt.event.InputEvent;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author xuedianfu
 */
public class AddBacNet extends javax.swing.JDialog {
    
    public ClientPluginTester cpt;
    private static volatile long i = 0;
    private DefaultTableModel tm;
    private String[] colums = new String[]{"数据"};
    private String[][] tableData = new String[][]{};
    private int rowIndex = -1;
    private BacNetAutoChecker bacNetAutoChecker;

    /**
     * Creates new form AddModbus
     */
    public AddBacNet(ClientPluginTester cpt, JSONObject initData) {
        super(cpt, true);
        this.cpt = cpt;
        initComponents();
        URL url = Thread.currentThread().getContextClassLoader().getResource("logo.gif");
        ImageIcon icon = new ImageIcon(url);
        setIconImage(icon.getImage());
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setLocationRelativeTo(this.cpt.getShellFrame());
        setMinimumSize(new Dimension(550, 700));
        setResizable(true);
        setTitle("代码飞舞采控系统-添加BacNet");
        
        init();
        initResultTable();
        initRequesItemtOprationMenus();
        initEditData(initData);
    }

    public ClientPluginTester getClientPluginTester(){
        return this.cpt;
    }

    private void initEditData(JSONObject initData){
        if(initData != null){
            JSONObject client = initData.getJSONObject("client");
            jtf_id.setText(client.getString("id"));
            JSONArray items = client.getJSONArray("items");
            for (int i = 0;i < items.size();i++){
                JSONObject jsonObject = items.getJSONObject(i);
                tm.addRow(new String[]{jsonObject.toJSONString()});
            }
            rowIndex = initData.getIntValue("rowIndex");
        }
    }

    private void initResultTable(){
        tm = new DefaultTableModel(tableData, colums);
        jt_result.setModel(tm);
    }

    private JPopupMenu paramHelpJpm;

    private void initRequesItemtOprationMenus() {
        paramHelpJpm = new JPopupMenu();
        JMenuItem mi_del = new JMenuItem("删除");
        mi_del.addActionListener(e -> {
            int[] selectedRows = jt_result.getSelectedRows();
            Arrays.sort(selectedRows);
            for(int i = selectedRows.length -1; i >=0; i--) {
                tm.removeRow(selectedRows[i]);
                getAutoincrement();
            }
        });
        paramHelpJpm.add(mi_del, 0);
        jt_result.add(paramHelpJpm);
    }
    
    private void init(){
        DefaultComboBoxModel<IntegerItem> cbm1 = new DefaultComboBoxModel<>();
        cbm1.addElement(new IntegerItem("ackedTransitions(0)", 0));
        cbm1.addElement(new IntegerItem("ackRequired(1)", 1));
        cbm1.addElement(new IntegerItem("action(2)", 2));
        cbm1.addElement(new IntegerItem("actionText(3)", 3));
        cbm1.addElement(new IntegerItem("activeText(4)", 4));
        cbm1.addElement(new IntegerItem("activeVtSessions(5)", 5));
        cbm1.addElement(new IntegerItem("alarmValue(6)", 6));
        cbm1.addElement(new IntegerItem("alarmValues(7)", 7));
        cbm1.addElement(new IntegerItem("all(8)", 8));
        cbm1.addElement(new IntegerItem("allWritesSuccessful(9)", 9));
        cbm1.addElement(new IntegerItem("apduSegmentTimeout(10)", 10));
        cbm1.addElement(new IntegerItem("apduTimeout(11)", 11));
        cbm1.addElement(new IntegerItem("applicationSoftwareVersion(12)", 12));
        cbm1.addElement(new IntegerItem("archive(13)", 13));
        cbm1.addElement(new IntegerItem("bias(14)", 14));
        cbm1.addElement(new IntegerItem("changeOfStateCount(15)", 15));
        cbm1.addElement(new IntegerItem("changeOfStateTime(16)", 16));
        cbm1.addElement(new IntegerItem("notificationClass(17)", 17));
        cbm1.addElement(new IntegerItem("controlledVariableReference(19)", 19));
        cbm1.addElement(new IntegerItem("controlledVariableUnits(20)", 20));
        cbm1.addElement(new IntegerItem("controlledVariableValue(21)", 21));
        cbm1.addElement(new IntegerItem("covIncrement(22)", 22));
        cbm1.addElement(new IntegerItem("dateList(23)", 23));
        cbm1.addElement(new IntegerItem("daylightSavingsStatus(24)", 24));
        cbm1.addElement(new IntegerItem("deadband(25)", 25));
        cbm1.addElement(new IntegerItem("derivativeConstant(26)", 26));
        cbm1.addElement(new IntegerItem("derivativeConstantUnits(27)", 27));
        cbm1.addElement(new IntegerItem("description(28)", 28));
        cbm1.addElement(new IntegerItem("descriptionOfHalt(29)", 29));
        cbm1.addElement(new IntegerItem("deviceAddressBinding(30)", 30));
        cbm1.addElement(new IntegerItem("deviceType(31)", 31));
        cbm1.addElement(new IntegerItem("effectivePeriod(32)", 32));
        cbm1.addElement(new IntegerItem("elapsedActiveTime(33)", 33));
        cbm1.addElement(new IntegerItem("errorLimit(34)", 34));
        cbm1.addElement(new IntegerItem("eventEnable(35)", 35));
        cbm1.addElement(new IntegerItem("eventState(36)", 36));
        cbm1.addElement(new IntegerItem("eventType(37)", 37));
        cbm1.addElement(new IntegerItem("exceptionSchedule(38)", 38));
        cbm1.addElement(new IntegerItem("faultValues(39)", 39));
        cbm1.addElement(new IntegerItem("feedbackValue(40)", 40));
        cbm1.addElement(new IntegerItem("fileAccessMethod(41)", 41));
        cbm1.addElement(new IntegerItem("fileSize(42)", 42));
        cbm1.addElement(new IntegerItem("fileType(43)", 43));
        cbm1.addElement(new IntegerItem("firmwareRevision(44)", 44));
        cbm1.addElement(new IntegerItem("highLimit(45)", 45));
        cbm1.addElement(new IntegerItem("inactiveText(46)", 46));
        cbm1.addElement(new IntegerItem("inProcess(47)", 47));
        cbm1.addElement(new IntegerItem("instanceOf(48)", 48));
        cbm1.addElement(new IntegerItem("integralConstant(49)", 49));
        cbm1.addElement(new IntegerItem("integralConstantUnits(50)", 50));
        cbm1.addElement(new IntegerItem("limitEnable(52)", 52));
        cbm1.addElement(new IntegerItem("listOfGroupMembers(53)", 53));
        cbm1.addElement(new IntegerItem("listOfObjectPropertyReferences(54)", 54));
        cbm1.addElement(new IntegerItem("localDate(56)", 56));
        cbm1.addElement(new IntegerItem("localTime(57)", 57));
        cbm1.addElement(new IntegerItem("location(58)", 58));
        cbm1.addElement(new IntegerItem("lowLimit(59)", 59));
        cbm1.addElement(new IntegerItem("manipulatedVariableReference(60)", 60));
        cbm1.addElement(new IntegerItem("maximumOutput(61)", 61));
        cbm1.addElement(new IntegerItem("maxApduLengthAccepted(62)", 62));
        cbm1.addElement(new IntegerItem("maxInfoFrames(63)", 63));
        cbm1.addElement(new IntegerItem("maxMaster(64)", 64));
        cbm1.addElement(new IntegerItem("maxPresValue(65)", 65));
        cbm1.addElement(new IntegerItem("minimumOffTime(66)", 66));
        cbm1.addElement(new IntegerItem("minimumOnTime(67)", 67));
        cbm1.addElement(new IntegerItem("minimumOutput(68)", 68));
        cbm1.addElement(new IntegerItem("minPresValue(69)", 69));
        cbm1.addElement(new IntegerItem("modelName(70)", 70));
        cbm1.addElement(new IntegerItem("modificationDate(71)", 71));
        cbm1.addElement(new IntegerItem("notifyType(72)", 72));
        cbm1.addElement(new IntegerItem("numberOfApduRetries(73)", 73));
        cbm1.addElement(new IntegerItem("numberOfStates(74)", 74));
        cbm1.addElement(new IntegerItem("objectIdentifier(75)", 75));
        cbm1.addElement(new IntegerItem("objectList(76)", 76));
        cbm1.addElement(new IntegerItem("objectName(77)", 77));
        cbm1.addElement(new IntegerItem("objectPropertyReference(78)", 78));
        cbm1.addElement(new IntegerItem("objectType(79)", 79));
        cbm1.addElement(new IntegerItem("optional(80)", 80));
        cbm1.addElement(new IntegerItem("outOfService(81)", 81));
        cbm1.addElement(new IntegerItem("outputUnits(82)", 82));
        cbm1.addElement(new IntegerItem("eventParameters(83)", 83));
        cbm1.addElement(new IntegerItem("polarity(84)", 84));
        cbm1.addElement(new IntegerItem("presentValue(85)", 85));
        cbm1.addElement(new IntegerItem("priority(86)", 86));
        cbm1.addElement(new IntegerItem("priorityArray(87)", 87));
        cbm1.addElement(new IntegerItem("priorityForWriting(88)", 88));
        cbm1.addElement(new IntegerItem("processIdentifier(89)", 89));
        cbm1.addElement(new IntegerItem("programChange(90)", 90));
        cbm1.addElement(new IntegerItem("programLocation(91)", 91));
        cbm1.addElement(new IntegerItem("programState(92)", 92));
        cbm1.addElement(new IntegerItem("proportionalConstant(93)", 93));
        cbm1.addElement(new IntegerItem("proportionalConstantUnits(94)", 94));
        cbm1.addElement(new IntegerItem("protocolObjectTypesSupported(96)", 96));
        cbm1.addElement(new IntegerItem("protocolServicesSupported(97)", 97));
        cbm1.addElement(new IntegerItem("protocolVersion(98)", 98));
        cbm1.addElement(new IntegerItem("readOnly(99)", 99));
        cbm1.addElement(new IntegerItem("reasonForHalt(100)", 100));
        cbm1.addElement(new IntegerItem("recipientList(102)", 102));
        cbm1.addElement(new IntegerItem("reliability(103)", 103));
        cbm1.addElement(new IntegerItem("relinquishDefault(104)", 104));
        cbm1.addElement(new IntegerItem("required(105)", 105));
        cbm1.addElement(new IntegerItem("resolution(106)", 106));
        cbm1.addElement(new IntegerItem("segmentationSupported(107)", 107));
        cbm1.addElement(new IntegerItem("setpoint(108)", 108));
        cbm1.addElement(new IntegerItem("setpointReference(109)", 109));
        cbm1.addElement(new IntegerItem("stateText(110)", 110));
        cbm1.addElement(new IntegerItem("statusFlags(111)", 111));
        cbm1.addElement(new IntegerItem("systemStatus(112)", 112));
        cbm1.addElement(new IntegerItem("timeDelay(113)", 113));
        cbm1.addElement(new IntegerItem("timeOfActiveTimeReset(114)", 114));
        cbm1.addElement(new IntegerItem("timeOfStateCountReset(115)", 115));
        cbm1.addElement(new IntegerItem("timeSynchronizationRecipients(116)", 116));
        cbm1.addElement(new IntegerItem("units(117)", 117));
        cbm1.addElement(new IntegerItem("updateInterval(118)", 118));
        cbm1.addElement(new IntegerItem("utcOffset(119)", 119));
        cbm1.addElement(new IntegerItem("vendorIdentifier(120)", 120));
        cbm1.addElement(new IntegerItem("vendorName(121)", 121));
        cbm1.addElement(new IntegerItem("vtClassesSupported(122)", 122));
        cbm1.addElement(new IntegerItem("weeklySchedule(123)", 123));
        cbm1.addElement(new IntegerItem("attemptedSamples(124)", 124));
        cbm1.addElement(new IntegerItem("averageValue(125)", 125));
        cbm1.addElement(new IntegerItem("bufferSize(126)", 126));
        cbm1.addElement(new IntegerItem("clientCovIncrement(127)", 127));
        cbm1.addElement(new IntegerItem("covResubscriptionInterval(128)", 128));
        cbm1.addElement(new IntegerItem("eventTimeStamps(130)", 130));
        cbm1.addElement(new IntegerItem("logBuffer(131)", 131));
        cbm1.addElement(new IntegerItem("logDeviceObjectProperty(132)", 132));
        cbm1.addElement(new IntegerItem("enable(133)", 133));
        cbm1.addElement(new IntegerItem("logInterval(134)", 134));
        cbm1.addElement(new IntegerItem("maximumValue(135)", 135));
        cbm1.addElement(new IntegerItem("minimumValue(136)", 136));
        cbm1.addElement(new IntegerItem("notificationThreshold(137)", 137));
        cbm1.addElement(new IntegerItem("protocolRevision(139)", 139));
        cbm1.addElement(new IntegerItem("recordsSinceNotification(140)", 140));
        cbm1.addElement(new IntegerItem("recordCount(141)", 141));
        cbm1.addElement(new IntegerItem("startTime(142)", 142));
        cbm1.addElement(new IntegerItem("stopTime(143)", 143));
        cbm1.addElement(new IntegerItem("stopWhenFull(144)", 144));
        cbm1.addElement(new IntegerItem("totalRecordCount(145)", 145));
        cbm1.addElement(new IntegerItem("validSamples(146)", 146));
        cbm1.addElement(new IntegerItem("windowInterval(147)", 147));
        cbm1.addElement(new IntegerItem("windowSamples(148)", 148));
        cbm1.addElement(new IntegerItem("maximumValueTimestamp(149)", 149));
        cbm1.addElement(new IntegerItem("minimumValueTimestamp(150)", 150));
        cbm1.addElement(new IntegerItem("varianceValue(151)", 151));
        cbm1.addElement(new IntegerItem("activeCovSubscriptions(152)", 152));
        cbm1.addElement(new IntegerItem("backupFailureTimeout(153)", 153));
        cbm1.addElement(new IntegerItem("configurationFiles(154)", 154));
        cbm1.addElement(new IntegerItem("databaseRevision(155)", 155));
        cbm1.addElement(new IntegerItem("directReading(156)", 156));
        cbm1.addElement(new IntegerItem("lastRestoreTime(157)", 157));
        cbm1.addElement(new IntegerItem("maintenanceRequired(158)", 158));
        cbm1.addElement(new IntegerItem("memberOf(159)", 159));
        cbm1.addElement(new IntegerItem("mode(160)", 160));
        cbm1.addElement(new IntegerItem("operationExpected(161)", 161));
        cbm1.addElement(new IntegerItem("setting(162)", 162));
        cbm1.addElement(new IntegerItem("silenced(163)", 163));
        cbm1.addElement(new IntegerItem("trackingValue(164)", 164));
        cbm1.addElement(new IntegerItem("zoneMembers(165)", 165));
        cbm1.addElement(new IntegerItem("lifeSafetyAlarmValues(166)", 166));
        cbm1.addElement(new IntegerItem("maxSegmentsAccepted(167)", 167));
        cbm1.addElement(new IntegerItem("profileName(168)", 168));
        cbm1.addElement(new IntegerItem("autoSlaveDiscovery(169)", 169));
        cbm1.addElement(new IntegerItem("manualSlaveAddressBinding(170)", 170));
        cbm1.addElement(new IntegerItem("slaveAddressBinding(171)", 171));
        cbm1.addElement(new IntegerItem("slaveProxyEnable(172)", 172));
        cbm1.addElement(new IntegerItem("lastNotifyRecord(173)", 173));
        cbm1.addElement(new IntegerItem("scheduleDefault(174)", 174));
        cbm1.addElement(new IntegerItem("acceptedModes(175)", 175));
        cbm1.addElement(new IntegerItem("adjustValue(176)", 176));
        cbm1.addElement(new IntegerItem("count(177)", 177));
        cbm1.addElement(new IntegerItem("countBeforeChange(178)", 178));
        cbm1.addElement(new IntegerItem("countChangeTime(179)", 179));
        cbm1.addElement(new IntegerItem("covPeriod(180)", 180));
        cbm1.addElement(new IntegerItem("inputReference(181)", 181));
        cbm1.addElement(new IntegerItem("limitMonitoringInterval(182)", 182));
        cbm1.addElement(new IntegerItem("loggingObject(183)", 183));
        cbm1.addElement(new IntegerItem("loggingRecord(184)", 184));
        cbm1.addElement(new IntegerItem("prescale(185)", 185));
        cbm1.addElement(new IntegerItem("pulseRate(186)", 186));
        cbm1.addElement(new IntegerItem("scale(187)", 187));
        cbm1.addElement(new IntegerItem("scaleFactor(188)", 188));
        cbm1.addElement(new IntegerItem("updateTime(189)", 189));
        cbm1.addElement(new IntegerItem("valueBeforeChange(190)", 190));
        cbm1.addElement(new IntegerItem("valueSet(191)", 191));
        cbm1.addElement(new IntegerItem("valueChangeTime(192)", 192));
        cbm1.addElement(new IntegerItem("alignIntervals(193)", 193));
        cbm1.addElement(new IntegerItem("intervalOffset(195)", 195));
        cbm1.addElement(new IntegerItem("lastRestartReason(196)", 196));
        cbm1.addElement(new IntegerItem("loggingType(197)", 197));
        cbm1.addElement(new IntegerItem("restartNotificationRecipients(202)", 202));
        cbm1.addElement(new IntegerItem("timeOfDeviceRestart(203)", 203));
        cbm1.addElement(new IntegerItem("timeSynchronizationInterval(204)", 204));
        cbm1.addElement(new IntegerItem("trigger(205)", 205));
        cbm1.addElement(new IntegerItem("utcTimeSynchronizationRecipients(206)", 206));
        cbm1.addElement(new IntegerItem("nodeSubtype(207)", 207));
        cbm1.addElement(new IntegerItem("nodeType(208)", 208));
        cbm1.addElement(new IntegerItem("structuredObjectList(209)", 209));
        cbm1.addElement(new IntegerItem("subordinateAnnotations(210)", 210));
        cbm1.addElement(new IntegerItem("subordinateList(211)", 211));
        cbm1.addElement(new IntegerItem("actualShedLevel(212)", 212));
        cbm1.addElement(new IntegerItem("dutyWindow(213)", 213));
        cbm1.addElement(new IntegerItem("expectedShedLevel(214)", 214));
        cbm1.addElement(new IntegerItem("fullDutyBaseline(215)", 215));
        cbm1.addElement(new IntegerItem("requestedShedLevel(218)", 218));
        cbm1.addElement(new IntegerItem("shedDuration(219)", 219));
        cbm1.addElement(new IntegerItem("shedLevelDescriptions(220)", 220));
        cbm1.addElement(new IntegerItem("shedLevels(221)", 221));
        cbm1.addElement(new IntegerItem("stateDescription(222)", 222));
        cbm1.addElement(new IntegerItem("doorAlarmState(226)", 226));
        cbm1.addElement(new IntegerItem("doorExtendedPulseTime(227)", 227));
        cbm1.addElement(new IntegerItem("doorMembers(228)", 228));
        cbm1.addElement(new IntegerItem("doorOpenTooLongTime(229)", 229));
        cbm1.addElement(new IntegerItem("doorPulseTime(230)", 230));
        cbm1.addElement(new IntegerItem("doorStatus(231)", 231));
        cbm1.addElement(new IntegerItem("doorUnlockDelayTime(232)", 232));
        cbm1.addElement(new IntegerItem("lockStatus(233)", 233));
        cbm1.addElement(new IntegerItem("maskedAlarmValues(234)", 234));
        cbm1.addElement(new IntegerItem("securedStatus(235)", 235));
        cbm1.addElement(new IntegerItem("absenteeLimit(244)", 244));
        cbm1.addElement(new IntegerItem("accessAlarmEvents(245)", 245));
        cbm1.addElement(new IntegerItem("accessDoors(246)", 246));
        cbm1.addElement(new IntegerItem("accessEvent(247)", 247));
        cbm1.addElement(new IntegerItem("accessEventAuthenticationFactor(248)", 248));
        cbm1.addElement(new IntegerItem("accessEventCredential(249)", 249));
        cbm1.addElement(new IntegerItem("accessEventTime(250)", 250));
        cbm1.addElement(new IntegerItem("accessTransactionEvents(251)", 251));
        cbm1.addElement(new IntegerItem("accompaniment(252)", 252));
        cbm1.addElement(new IntegerItem("accompanimentTime(253)", 253));
        cbm1.addElement(new IntegerItem("activationTime(254)", 254));
        cbm1.addElement(new IntegerItem("activeAuthenticationPolicy(255)", 255));
        cbm1.addElement(new IntegerItem("assignedAccessRights(256)", 256));
        cbm1.addElement(new IntegerItem("authenticationFactors(257)", 257));
        cbm1.addElement(new IntegerItem("authenticationPolicyList(258)", 258));
        cbm1.addElement(new IntegerItem("authenticationPolicyNames(259)", 259));
        cbm1.addElement(new IntegerItem("authenticationStatus(260)", 260));
        cbm1.addElement(new IntegerItem("authorizationMode(261)", 261));
        cbm1.addElement(new IntegerItem("belongsTo(262)", 262));
        cbm1.addElement(new IntegerItem("credentialDisable(263)", 263));
        cbm1.addElement(new IntegerItem("credentialStatus(264)", 264));
        cbm1.addElement(new IntegerItem("credentials(265)", 265));
        cbm1.addElement(new IntegerItem("credentialsInZone(266)", 266));
        cbm1.addElement(new IntegerItem("daysRemaining(267)", 267));
        cbm1.addElement(new IntegerItem("entryPoints(268)", 268));
        cbm1.addElement(new IntegerItem("exitPoints(269)", 269));
        cbm1.addElement(new IntegerItem("expirationTime(270)", 270));
        cbm1.addElement(new IntegerItem("extendedTimeEnable(271)", 271));
        cbm1.addElement(new IntegerItem("failedAttemptEvents(272)", 272));
        cbm1.addElement(new IntegerItem("failedAttempts(273)", 273));
        cbm1.addElement(new IntegerItem("failedAttemptsTime(274)", 274));
        cbm1.addElement(new IntegerItem("lastAccessEvent(275)", 275));
        cbm1.addElement(new IntegerItem("lastAccessPoint(276)", 276));
        cbm1.addElement(new IntegerItem("lastCredentialAdded(277)", 277));
        cbm1.addElement(new IntegerItem("lastCredentialAddedTime(278)", 278));
        cbm1.addElement(new IntegerItem("lastCredentialRemoved(279)", 279));
        cbm1.addElement(new IntegerItem("lastCredentialRemovedTime(280)", 280));
        cbm1.addElement(new IntegerItem("lastUseTime(281)", 281));
        cbm1.addElement(new IntegerItem("lockout(282)", 282));
        cbm1.addElement(new IntegerItem("lockoutRelinquishTime(283)", 283));
        cbm1.addElement(new IntegerItem("maxFailedAttempts(285)", 285));
        cbm1.addElement(new IntegerItem("members(286)", 286));
        cbm1.addElement(new IntegerItem("musterPoint(287)", 287));
        cbm1.addElement(new IntegerItem("negativeAccessRules(288)", 288));
        cbm1.addElement(new IntegerItem("numberOfAuthenticationPolicies(289)", 289));
        cbm1.addElement(new IntegerItem("occupancyCount(290)", 290));
        cbm1.addElement(new IntegerItem("occupancyCountAdjust(291)", 291));
        cbm1.addElement(new IntegerItem("occupancyCountEnable(292)", 292));
        cbm1.addElement(new IntegerItem("occupancyLowerLimit(294)", 294));
        cbm1.addElement(new IntegerItem("occupancyLowerLimitEnforced(295)", 295));
        cbm1.addElement(new IntegerItem("occupancyState(296)", 296));
        cbm1.addElement(new IntegerItem("occupancyUpperLimit(297)", 297));
        cbm1.addElement(new IntegerItem("occupancyUpperLimitEnforced(298)", 298));
        cbm1.addElement(new IntegerItem("passbackMode(300)", 300));
        cbm1.addElement(new IntegerItem("passbackTimeout(301)", 301));
        cbm1.addElement(new IntegerItem("positiveAccessRules(302)", 302));
        cbm1.addElement(new IntegerItem("reasonForDisable(303)", 303));
        cbm1.addElement(new IntegerItem("supportedFormats(304)", 304));
        cbm1.addElement(new IntegerItem("supportedFormatClasses(305)", 305));
        cbm1.addElement(new IntegerItem("threatAuthority(306)", 306));
        cbm1.addElement(new IntegerItem("threatLevel(307)", 307));
        cbm1.addElement(new IntegerItem("traceFlag(308)", 308));
        cbm1.addElement(new IntegerItem("transactionNotificationClass(309)", 309));
        cbm1.addElement(new IntegerItem("userExternalIdentifier(310)", 310));
        cbm1.addElement(new IntegerItem("userInformationReference(311)", 311));
        cbm1.addElement(new IntegerItem("userName(317)", 317));
        cbm1.addElement(new IntegerItem("userType(318)", 318));
        cbm1.addElement(new IntegerItem("usesRemaining(319)", 319));
        cbm1.addElement(new IntegerItem("zoneFrom(320)", 320));
        cbm1.addElement(new IntegerItem("zoneTo(321)", 321));
        cbm1.addElement(new IntegerItem("accessEventTag(322)", 322));
        cbm1.addElement(new IntegerItem("globalIdentifier(323)", 323));
        cbm1.addElement(new IntegerItem("verificationTime(326)", 326));
        cbm1.addElement(new IntegerItem("baseDeviceSecurityPolicy(327)", 327));
        cbm1.addElement(new IntegerItem("distributionKeyRevision(328)", 328));
        cbm1.addElement(new IntegerItem("doNotHide(329)", 329));
        cbm1.addElement(new IntegerItem("keySets(330)", 330));
        cbm1.addElement(new IntegerItem("lastKeyServer(331)", 331));
        cbm1.addElement(new IntegerItem("networkAccessSecurityPolicies(332)", 332));
        cbm1.addElement(new IntegerItem("packetReorderTime(333)", 333));
        cbm1.addElement(new IntegerItem("securityPduTimeout(334)", 334));
        cbm1.addElement(new IntegerItem("securityTimeWindow(335)", 335));
        cbm1.addElement(new IntegerItem("supportedSecurityAlgorithms(336)", 336));
        cbm1.addElement(new IntegerItem("updateKeySetTimeout(337)", 337));
        cbm1.addElement(new IntegerItem("backupAndRestoreState(338)", 338));
        cbm1.addElement(new IntegerItem("backupPreparationTime(339)", 339));
        cbm1.addElement(new IntegerItem("restoreCompletionTime(340)", 340));
        cbm1.addElement(new IntegerItem("restorePreparationTime(341)", 341));
        cbm1.addElement(new IntegerItem("bitMask(342)", 342));
        cbm1.addElement(new IntegerItem("bitText(343)", 343));
        cbm1.addElement(new IntegerItem("isUtc(344)", 344));
        cbm1.addElement(new IntegerItem("groupMembers(345)", 345));
        cbm1.addElement(new IntegerItem("groupMemberNames(346)", 346));
        cbm1.addElement(new IntegerItem("memberStatusFlags(347)", 347));
        cbm1.addElement(new IntegerItem("requestedUpdateInterval(348)", 348));
        cbm1.addElement(new IntegerItem("covuPeriod(349)", 349));
        cbm1.addElement(new IntegerItem("covuRecipients(350)", 350));
        cbm1.addElement(new IntegerItem("eventMessageTexts(351)", 351));
        cbm1.addElement(new IntegerItem("eventMessageTextsConfig(352)", 352));
        cbm1.addElement(new IntegerItem("eventDetectionEnable(353)", 353));
        cbm1.addElement(new IntegerItem("eventAlgorithmInhibit(354)", 354));
        cbm1.addElement(new IntegerItem("eventAlgorithmInhibitRef(355)", 355));
        cbm1.addElement(new IntegerItem("timeDelayNormal(356)", 356));
        cbm1.addElement(new IntegerItem("reliabilityEvaluationInhibit(357)", 357));
        cbm1.addElement(new IntegerItem("faultParameters(358)", 358));
        cbm1.addElement(new IntegerItem("faultType(359)", 359));
        cbm1.addElement(new IntegerItem("localForwardingOnly(360)", 360));
        cbm1.addElement(new IntegerItem("processIdentifierFilter(361)", 361));
        cbm1.addElement(new IntegerItem("subscribedRecipients(362)", 362));
        cbm1.addElement(new IntegerItem("portFilter(363)", 363));
        cbm1.addElement(new IntegerItem("authorizationExemptions(364)", 364));
        cbm1.addElement(new IntegerItem("allowGroupDelayInhibit(365)", 365));
        cbm1.addElement(new IntegerItem("channelNumber(366)", 366));
        cbm1.addElement(new IntegerItem("controlGroups(367)", 367));
        cbm1.addElement(new IntegerItem("executionDelay(368)", 368));
        cbm1.addElement(new IntegerItem("lastPriority(369)", 369));
        cbm1.addElement(new IntegerItem("writeStatus(370)", 370));
        cbm1.addElement(new IntegerItem("propertyList(371)", 371));
        cbm1.addElement(new IntegerItem("serialNumber(372)", 372));
        cbm1.addElement(new IntegerItem("blinkWarnEnable(373)", 373));
        cbm1.addElement(new IntegerItem("defaultFadeTime(374)", 374));
        cbm1.addElement(new IntegerItem("defaultRampRate(375)", 375));
        cbm1.addElement(new IntegerItem("defaultStepIncrement(376)", 376));
        cbm1.addElement(new IntegerItem("egressTime(377)", 377));
        cbm1.addElement(new IntegerItem("inProgress(378)", 378));
        cbm1.addElement(new IntegerItem("instantaneousPower(379)", 379));
        cbm1.addElement(new IntegerItem("lightingCommand(380)", 380));
        cbm1.addElement(new IntegerItem("lightingCommandDefaultPriority(381)", 381));
        cbm1.addElement(new IntegerItem("maxActualValue(382)", 382));
        cbm1.addElement(new IntegerItem("minActualValue(383)", 383));
        cbm1.addElement(new IntegerItem("power(384)", 384));
        cbm1.addElement(new IntegerItem("transition(385)", 385));
        cbm1.addElement(new IntegerItem("egressActive(386)", 386));
        cbm1.addElement(new IntegerItem("interfaceValue(387)", 387));
        cbm1.addElement(new IntegerItem("faultHighLimit(388)", 388));
        cbm1.addElement(new IntegerItem("faultLowLimit(389)", 389));
        cbm1.addElement(new IntegerItem("lowDiffLimit(390)", 390));
        cbm1.addElement(new IntegerItem("strikeCount(391)", 391));
        cbm1.addElement(new IntegerItem("timeOfStrikeCountReset(392)", 392));
        cbm1.addElement(new IntegerItem("defaultTimeout(393)", 393));
        cbm1.addElement(new IntegerItem("initialTimeout(394)", 394));
        cbm1.addElement(new IntegerItem("lastStateChange(395)", 395));
        cbm1.addElement(new IntegerItem("stateChangeValues(396)", 396));
        cbm1.addElement(new IntegerItem("timerRunning(397)", 397));
        cbm1.addElement(new IntegerItem("timerState(398)", 398));
        cbm1.addElement(new IntegerItem("apduLength(399)", 399));
        cbm1.addElement(new IntegerItem("ipAddress(400)", 400));
        cbm1.addElement(new IntegerItem("ipDefaultGateway(401)", 401));
        cbm1.addElement(new IntegerItem("ipDhcpEnable(402)", 402));
        cbm1.addElement(new IntegerItem("ipDhcpLeaseTime(403)", 403));
        cbm1.addElement(new IntegerItem("ipDhcpLeaseTimeRemaining(404)", 404));
        cbm1.addElement(new IntegerItem("ipDhcpServer(405)", 405));
        cbm1.addElement(new IntegerItem("ipDnsServer(406)", 406));
        cbm1.addElement(new IntegerItem("bacnetIpGlobalAddress(407)", 407));
        cbm1.addElement(new IntegerItem("bacnetIpMode(408)", 408));
        cbm1.addElement(new IntegerItem("bacnetIpMulticastAddress(409)", 409));
        cbm1.addElement(new IntegerItem("bacnetIpNatTraversal(410)", 410));
        cbm1.addElement(new IntegerItem("ipSubnetMask(411)", 411));
        cbm1.addElement(new IntegerItem("bacnetIpUdpPort(412)", 412));
        cbm1.addElement(new IntegerItem("bbmdAcceptFdRegistrations(413)", 413));
        cbm1.addElement(new IntegerItem("bbmdBroadcastDistributionTable(414)", 414));
        cbm1.addElement(new IntegerItem("bbmdForeignDeviceTable(415)", 415));
        cbm1.addElement(new IntegerItem("changesPending(416)", 416));
        cbm1.addElement(new IntegerItem("command(417)", 417));
        cbm1.addElement(new IntegerItem("fdBbmdAddress(418)", 418));
        cbm1.addElement(new IntegerItem("fdSubscriptionLifetime(419)", 419));
        cbm1.addElement(new IntegerItem("linkSpeed(420)", 420));
        cbm1.addElement(new IntegerItem("linkSpeeds(421)", 421));
        cbm1.addElement(new IntegerItem("linkSpeedAutonegotiate(422)", 422));
        cbm1.addElement(new IntegerItem("macAddress(423)", 423));
        cbm1.addElement(new IntegerItem("networkInterfaceName(424)", 424));
        cbm1.addElement(new IntegerItem("networkNumber(425)", 425));
        cbm1.addElement(new IntegerItem("networkNumberQuality(426)", 426));
        cbm1.addElement(new IntegerItem("networkType(427)", 427));
        cbm1.addElement(new IntegerItem("routingTable(428)", 428));
        cbm1.addElement(new IntegerItem("virtualMacAddressTable(429)", 429));
        cbm1.addElement(new IntegerItem("commandTimeArray(430)", 430));
        cbm1.addElement(new IntegerItem("currentCommandPriority(431)", 431));
        cbm1.addElement(new IntegerItem("lastCommandTime(432)", 432));
        cbm1.addElement(new IntegerItem("valueSource(433)", 433));
        cbm1.addElement(new IntegerItem("valueSourceArray(434)", 434));
        cbm1.addElement(new IntegerItem("Mode(6)", 6));
        cbm1.addElement(new IntegerItem("Address(6)", 6));
        cbm1.addElement(new IntegerItem("PrefixLength(6)", 6));
        cbm1.addElement(new IntegerItem("UdpPort(6)", 6));
        cbm1.addElement(new IntegerItem("DefaultGateway(6)", 6));
        cbm1.addElement(new IntegerItem("MulticastAddress(6)", 6));
        cbm1.addElement(new IntegerItem("DnsServer(6)", 6));
        cbm1.addElement(new IntegerItem("AutoAddressingEnable(6)", 6));
        cbm1.addElement(new IntegerItem("DhcpLeaseTime(6)", 6));
        cbm1.addElement(new IntegerItem("DhcpLeaseTimeRemaining(6)", 6));
        cbm1.addElement(new IntegerItem("DhcpServer(6)", 6));
        cbm1.addElement(new IntegerItem("ZoneIndex(6)", 6));
        cbm1.addElement(new IntegerItem("assignedLandingCalls(447)", 447));
        cbm1.addElement(new IntegerItem("carAssignedDirection(448)", 448));
        cbm1.addElement(new IntegerItem("carDoorCommand(449)", 449));
        cbm1.addElement(new IntegerItem("carDoorStatus(450)", 450));
        cbm1.addElement(new IntegerItem("carDoorText(451)", 451));
        cbm1.addElement(new IntegerItem("carDoorZone(452)", 452));
        cbm1.addElement(new IntegerItem("carDriveStatus(453)", 453));
        cbm1.addElement(new IntegerItem("carLoad(454)", 454));
        cbm1.addElement(new IntegerItem("carLoadUnits(455)", 455));
        cbm1.addElement(new IntegerItem("carMode(456)", 456));
        cbm1.addElement(new IntegerItem("carMovingDirection(457)", 457));
        cbm1.addElement(new IntegerItem("carPosition(458)", 458));
        cbm1.addElement(new IntegerItem("elevatorGroup(459)", 459));
        cbm1.addElement(new IntegerItem("energyMeter(460)", 460));
        cbm1.addElement(new IntegerItem("energyMeterRef(461)", 461));
        cbm1.addElement(new IntegerItem("escalatorMode(462)", 462));
        cbm1.addElement(new IntegerItem("faultSignals(463)", 463));
        cbm1.addElement(new IntegerItem("floorText(464)", 464));
        cbm1.addElement(new IntegerItem("groupId(465)", 465));
        cbm1.addElement(new IntegerItem("groupMode(467)", 467));
        cbm1.addElement(new IntegerItem("higherDeck(468)", 468));
        cbm1.addElement(new IntegerItem("installationId(469)", 469));
        cbm1.addElement(new IntegerItem("landingCalls(470)", 470));
        cbm1.addElement(new IntegerItem("landingCallControl(471)", 471));
        cbm1.addElement(new IntegerItem("landingDoorStatus(472)", 472));
        cbm1.addElement(new IntegerItem("lowerDeck(473)", 473));
        cbm1.addElement(new IntegerItem("machineRoomId(474)", 474));
        cbm1.addElement(new IntegerItem("makingCarCall(475)", 475));
        cbm1.addElement(new IntegerItem("nextStoppingFloor(476)", 476));
        cbm1.addElement(new IntegerItem("operationDirection(477)", 477));
        cbm1.addElement(new IntegerItem("passengerAlarm(478)", 478));
        cbm1.addElement(new IntegerItem("powerMode(479)", 479));
        cbm1.addElement(new IntegerItem("registeredCarCall(480)", 480));
        cbm1.addElement(new IntegerItem("activeCovMultipleSubscriptions(481)", 481));
        cbm1.addElement(new IntegerItem("protocolLevel(482)", 482));
        cbm1.addElement(new IntegerItem("referencePort(483)", 483));
        cbm1.addElement(new IntegerItem("deployedProfileLocation(484)", 484));
        cbm1.addElement(new IntegerItem("profileLocation(485)", 485));
        cbm1.addElement(new IntegerItem("tags(486)", 486));
        cbm1.addElement(new IntegerItem("subordinateNodeTypes(487)", 487));
        cbm1.addElement(new IntegerItem("subordinateTags(488)", 488));
        cbm1.addElement(new IntegerItem("subordinateRelationships(489)", 489));
        cbm1.addElement(new IntegerItem("defaultSubordinateRelationship(490)", 490));
        cbm1.addElement(new IntegerItem("represents(491)", 491));
        jcb_property.setModel(cbm1);
        DefaultComboBoxModel<IntegerItem> cbm2 = new DefaultComboBoxModel<>();
        cbm2.addElement(new IntegerItem("analogInput: 0", 0));
        cbm2.addElement(new IntegerItem("analogOutput: 1", 1));
        cbm2.addElement(new IntegerItem("analogValue: 2", 2));
        cbm2.addElement(new IntegerItem("binaryInput: 3", 3));
        cbm2.addElement(new IntegerItem("binaryOutput: 4", 4));
        cbm2.addElement(new IntegerItem("binaryValue: 5", 5));
        cbm2.addElement(new IntegerItem("calendar: 6", 6));
        cbm2.addElement(new IntegerItem("command: 7", 7));
        cbm2.addElement(new IntegerItem("device: 8", 8));
        cbm2.addElement(new IntegerItem("eventEnrollment: 9", 9));
        cbm2.addElement(new IntegerItem("file: 10", 10));
        cbm2.addElement(new IntegerItem("group: 11", 11));
        cbm2.addElement(new IntegerItem("loop: 12", 12));
        cbm2.addElement(new IntegerItem("multiStateInput: 13", 13));
        cbm2.addElement(new IntegerItem("multiStateOutput: 14", 14));
        cbm2.addElement(new IntegerItem("notificationClass: 15", 15));
        cbm2.addElement(new IntegerItem("program: 16", 16));
        cbm2.addElement(new IntegerItem("schedule: 17", 17));
        cbm2.addElement(new IntegerItem("averaging: 18", 18));
        cbm2.addElement(new IntegerItem("multiStateValue: 19", 19));
        cbm2.addElement(new IntegerItem("trendLog: 20", 20));
        cbm2.addElement(new IntegerItem("lifeSafetyPoint: 21", 21));
        cbm2.addElement(new IntegerItem("lifeSafetyZone: 22", 22));
        cbm2.addElement(new IntegerItem("accumulator: 23", 23));
        cbm2.addElement(new IntegerItem("pulseConverter: 24", 24));
        cbm2.addElement(new IntegerItem("eventLog: 25", 25));
        cbm2.addElement(new IntegerItem("globalGroup: 26", 26));
        cbm2.addElement(new IntegerItem("trendLogMultiple: 27", 27));
        cbm2.addElement(new IntegerItem("loadControl: 28", 28));
        cbm2.addElement(new IntegerItem("structuredView: 29", 29));
        cbm2.addElement(new IntegerItem("accessDoor: 30", 30));
        cbm2.addElement(new IntegerItem("timer: 31", 31));
        cbm2.addElement(new IntegerItem("accessCredential: 32", 32));
        cbm2.addElement(new IntegerItem("accessPoint: 33", 33));
        cbm2.addElement(new IntegerItem("accessRights: 34", 34));
        cbm2.addElement(new IntegerItem("accessUser: 35", 35));
        cbm2.addElement(new IntegerItem("accessZone: 36", 36));
        cbm2.addElement(new IntegerItem("credentialDataInput: 37", 37));
        cbm2.addElement(new IntegerItem("networkSecurity: 38", 38));
        cbm2.addElement(new IntegerItem("bitstringValue: 39", 39));
        cbm2.addElement(new IntegerItem("characterstringValue: 40", 40));
        cbm2.addElement(new IntegerItem("datePatternValue: 41", 41));
        cbm2.addElement(new IntegerItem("dateValue: 42", 42));
        cbm2.addElement(new IntegerItem("datetimePatternValue: 43", 43));
        cbm2.addElement(new IntegerItem("datetimeValue: 44", 44));
        cbm2.addElement(new IntegerItem("integerValue: 45", 45));
        cbm2.addElement(new IntegerItem("largeAnalogValue: 46", 46));
        cbm2.addElement(new IntegerItem("octetstringValue: 47", 47));
        cbm2.addElement(new IntegerItem("positiveIntegerValue: 48", 48));
        cbm2.addElement(new IntegerItem("timePatternValue: 49", 49));
        cbm2.addElement(new IntegerItem("timeValue: 50", 50));
        cbm2.addElement(new IntegerItem("notificationForwarder: 51", 51));
        cbm2.addElement(new IntegerItem("alertEnrollment: 52", 52));
        cbm2.addElement(new IntegerItem("channel: 53", 53));
        cbm2.addElement(new IntegerItem("lightingOutput: 54", 54));
        cbm2.addElement(new IntegerItem("binaryLightingOutput: 55", 55));
        cbm2.addElement(new IntegerItem("networkPort: 56", 56));
        cbm2.addElement(new IntegerItem("elevatorGroup: 57", 57));
        cbm2.addElement(new IntegerItem("escalator: 58", 58));
        cbm2.addElement(new IntegerItem("lift: 59", 59));
        jcb_datatype.setModel(cbm2);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtf_id = new javax.swing.JTextField();
        jtf_deviceId = new javax.swing.JTextField();
        jtf_instance = new javax.swing.JTextField();
        jb_save = new javax.swing.JButton();
        jcb_property = new javax.swing.JComboBox<>();
        jcb_datatype = new javax.swing.JComboBox<>();
        jScrollPane1 = new javax.swing.JScrollPane();
        jt_result = new javax.swing.JTable();
        jb_add = new javax.swing.JButton();
        jb_clean = new javax.swing.JButton();
        jb_autoCheck = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("BACNet");

        jLabel2.setText("Client id：");

        jLabel3.setText("Device Id：");

        jLabel4.setText("Property：");

        jLabel5.setText("Instance：");

        jLabel6.setText("Data type：");

        jtf_id.setText("0");
        jtf_id.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtf_idKeyTyped(evt);
            }
        });

        jtf_deviceId.setText("1");
        jtf_deviceId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtf_deviceIdKeyTyped(evt);
            }
        });

        jtf_instance.setText("0");
        jtf_instance.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jtf_instanceKeyTyped(evt);
            }
        });

        jb_save.setText("保存为命令");
        jb_save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_saveActionPerformed(evt);
            }
        });

        jt_result.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jt_result.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jt_resultMousePressed(evt);
            }
        });
        jt_result.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jt_resultPropertyChange(evt);
            }
        });
        jScrollPane1.setViewportView(jt_result);

        jb_add.setText("添加");
        jb_add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_addActionPerformed(evt);
            }
        });

        jb_clean.setText("清空");
        jb_clean.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_cleanActionPerformed(evt);
            }
        });

        jb_autoCheck.setText("设备自检...");
        jb_autoCheck.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_autoCheckActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(19, 19, 19)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtf_instance, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jcb_property, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jcb_datatype, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(19, 19, 19)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtf_deviceId, javax.swing.GroupLayout.DEFAULT_SIZE, 419, Short.MAX_VALUE)
                                    .addComponent(jtf_id)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jb_add)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jb_save)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jb_clean)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jb_autoCheck)
                                .addGap(84, 84, 84)))
                        .addGap(38, 38, 38))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jScrollPane1)
                        .addContainerGap())))
            .addGroup(layout.createSequentialGroup()
                .addGap(244, 244, 244)
                .addComponent(jLabel1)
                .addContainerGap(261, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtf_id, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtf_deviceId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jcb_property, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtf_instance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jcb_datatype, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jb_save)
                    .addComponent(jb_add)
                    .addComponent(jb_clean)
                    .addComponent(jb_autoCheck))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jb_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_saveActionPerformed
        JSONObject commandParams = new JSONObject();
        commandParams.put("plugin", Command.BACNET_COMMAND);
        JSONArray data = new JSONArray();
        for(int i = 0; i < tm.getRowCount();i++){
            data.add(JSON.parseObject((String)tm.getValueAt(i, 0)));
        }
        JSONObject clientJo = new JSONObject();
        clientJo.put("id", Integer.valueOf(jtf_id.getText()));
        clientJo.put("items", data);
        commandParams.put("client", clientJo);
        if(rowIndex < 0) {
            String defaultName = "BacNet-" + getTime();
            String name = (String) JOptionPane.showInputDialog(this, "如需重新起名，请输入新的名称。", "保存命令", JOptionPane.QUESTION_MESSAGE, null, null, defaultName);
            if (name != null && !name.isEmpty()) {
                cpt.addPluginParam(commandParams, name);
                i = 0;
                setVisible(false);
            }
        }else{
            cpt.addPluginParam(commandParams, rowIndex);
            i = 0;
            setVisible(false);
        }
    }//GEN-LAST:event_jb_saveActionPerformed

    private String getTime(){
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        return sdf.format(new Date());
    }

    private long getAutoincrement(){
        i++;
        return i;
    }

    private void jb_addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_addActionPerformed
        JSONObject jo = new JSONObject();
        jo.put("tag", "tag" + getAutoincrement());
        jo.put("property", ((IntegerItem)jcb_property.getSelectedItem()).getValue());
        jo.put("deviceId", Integer.valueOf(jtf_deviceId.getText()));
        jo.put("instance", Integer.valueOf(jtf_instance.getText()));
        jo.put("datatype", ((IntegerItem)jcb_datatype.getSelectedItem()).getValue());
        tm.addRow(new String[]{jo.toJSONString()});
    }//GEN-LAST:event_jb_addActionPerformed

    private void jt_resultMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jt_resultMousePressed
        int mods = evt.getModifiers();
        if ((mods & InputEvent.BUTTON3_MASK) != 0) {
//            if (this.getExtendedState() == Frame.MAXIMIZED_BOTH) {
//                this.paramHelpJpm.show(this, evt.getX(), evt.getYOnScreen() + this.paramHelpJpm.getHeight() / 2);
//            } else {
                this.paramHelpJpm.show(this, evt.getX(), evt.getYOnScreen() - 180);
//            }
        }
    }//GEN-LAST:event_jt_resultMousePressed

    private void jb_cleanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_cleanActionPerformed
        for(int i = jt_result.getRowCount() -1; i >=0; i--) {
            tm.removeRow(i);
        }
    }//GEN-LAST:event_jb_cleanActionPerformed

    private void jt_resultPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jt_resultPropertyChange

    }//GEN-LAST:event_jt_resultPropertyChange

    private void jb_autoCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_autoCheckActionPerformed
        if(bacNetAutoChecker == null) {
            bacNetAutoChecker = new BacNetAutoChecker(this);
            bacNetAutoChecker.setLocationRelativeTo(this);
        }
        bacNetAutoChecker.setClientId(this.jtf_id.getText());
        bacNetAutoChecker.setVisible(true);
    }//GEN-LAST:event_jb_autoCheckActionPerformed

    private void jtf_idKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtf_idKeyTyped
        JTextField jtf = (JTextField)evt.getSource();
        if (!TerminalApplication.numbers.contains(evt.getKeyChar())) {
            evt.consume();
        }
        try{
            Integer.parseInt(jtf.getText());
            if(jtf.getText().startsWith("0")){
                jtf.setText(jtf.getText().replaceAll("^0+", ""));
            }
        }catch (Exception e){
            jtf.setText("0");
        }
    }//GEN-LAST:event_jtf_idKeyTyped

    private void jtf_deviceIdKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtf_deviceIdKeyTyped
        jtf_idKeyTyped(evt);
    }//GEN-LAST:event_jtf_deviceIdKeyTyped

    private void jtf_instanceKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtf_instanceKeyTyped
        jtf_idKeyTyped(evt);
    }//GEN-LAST:event_jtf_instanceKeyTyped

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jb_add;
    private javax.swing.JButton jb_autoCheck;
    private javax.swing.JButton jb_clean;
    private javax.swing.JButton jb_save;
    private javax.swing.JComboBox<IntegerItem> jcb_datatype;
    private javax.swing.JComboBox<IntegerItem> jcb_property;
    private javax.swing.JTable jt_result;
    private javax.swing.JTextField jtf_deviceId;
    private javax.swing.JTextField jtf_id;
    private javax.swing.JTextField jtf_instance;
    // End of variables declaration//GEN-END:variables
}
